package com.example.myspringboot.test;

import com.example.myspringboot.service.TestServer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zheng
 */
@Service
public class MyServiceDemo {

    private final TestServer myRepository;

    public MyServiceDemo(TestServer myRepository) {
        this.myRepository = myRepository;
    }

    @Transactional
    public void performTransactionalOperation() {
        // 执行一些数据库操作
        // 如果这里抛出异常，那么上面的操作会被回滚
        // ... 其他数据库操作 ...
    }
}